﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace kwzx.Common
{
    public class CallProc
    {
    

        /// <summary>
        /// 部门调用存储过程
        /// </summary>
        /// <param name="deptID">部门ID</param>
        /// <param name="deptParentID">上级部门为0时，为上级机构编号，不为0时为上级部门编号。 </param>
        /// <param name="DeptName">部门名称</param>
        /// <param name="isGroup">上级部门是否为机构   机构:true,否则：false</param>
        /// <returns></returns>
        public int DeptEx(string deptID, int deptParentID, string DeptName, bool isGroup)
        {

          
            DBHelperEX dbHelper = new DBHelperEX();
            SqlParameter[] paras = { 
                               dbHelper.MakeInPara("@dep_no_add",SqlDbType.VarChar,50,deptID),
                               dbHelper.MakeInPara("@dep_no_parent",SqlDbType.VarChar,50,deptParentID.ToString()),
                               dbHelper.MakeInPara("@dep_name",SqlDbType.VarChar,50,DeptName),
                               };
            int result = dbHelper.ExecProc("updateDep", paras);
            return result;
        }

        /// <summary>
        /// 部门机构删除存储过程 
        /// </summary>
        /// <param name="deptID">部门机构ID</param>
        /// <param name="isGroup">是否为机构  true deptID 为机构  false deptID 为机构ID </param>
        /// <returns></returns>
        public int DeptDelEx(int deptID, bool isGroup)
        {
         
            DBHelperEX dbHelper = new DBHelperEX();
            SqlParameter[] paras = { 
                               dbHelper.MakeInPara("@dep_no_add",SqlDbType.VarChar,50,deptID),
                               };
            int result = dbHelper.ExecProc("deleteDep", paras);
            return result;
        }



        /// <summary>
        /// 人员档案新增修改调用存储过程
        /// </summary>
        /// <param name="userNo">员工编号</param>
        /// <param name="user_lname">姓名</param>
        /// <param name="user_photo">是否有照片  有1  无0</param>
        /// <param name="user_sex">性别</param>
        /// <param name="user_id">身份证号</param>
        /// <param name="user_type">人员类型0-正常,1-离职</param>
        /// <param name="dep_no_add">旧的部门编号</param>
        /// <returns></returns>
        public string UserEx(string userNo, string user_lname, int user_photo, string user_sex, string user_id, int user_type, string dep_no_add)
        {
            DBHelperEX dbHelper = new DBHelperEX();
            SqlParameter[] paras = { 
                               dbHelper.MakeInPara("@user_no",SqlDbType.VarChar,50,userNo),
                               dbHelper.MakeInPara("@user_lname",SqlDbType.VarChar,50,user_lname),
                               dbHelper.MakeInPara("@user_photo",SqlDbType.Int,4,user_photo),
                                dbHelper.MakeInPara("@user_sex",SqlDbType.VarChar,50,user_sex),
                               dbHelper.MakeInPara("@user_id",SqlDbType.VarChar,50,user_id),
                               dbHelper.MakeInPara("@user_type",SqlDbType.Int,4,user_type),
                               dbHelper.MakeInPara("@dep_no_add",SqlDbType.VarChar,50,dep_no_add),
                               dbHelper.MakePara("@outphotoname",SqlDbType.VarChar,50,ParameterDirection.Output,""),

                               };
            paras[7].Direction = ParameterDirection.Output;
            int result = dbHelper.ExecProc("archives_app", paras);
            return paras[7].Value.ToString();
        }

        /// <summary>
        /// 挂失人员  
        /// </summary>
        /// <param name="userNo">用户编号</param>
        /// <returns></returns>
        public int UserLossEx(string userNo)
        {
            DBHelperEX dbHelper = new DBHelperEX();
            SqlParameter[] paras = { 
                               dbHelper.MakeInPara("@user_no",SqlDbType.VarChar,50,userNo),
                               };

            int result = dbHelper.ExecProc("archives_gs", paras);
            return result;
        }


    }
}
